package com.suray.attendance.common.dingding;

import com.aliyun.teaopenapi.models.Config;

/**
 * @Author: jianglinyu
 * @CreateTime: 2023-07-05  09:22
 * @Description: 钉钉的客户端连接工具类
 * @Version: 1.0
 */
public class DingTalkClientUtils {

    /**
     * 使用 Token 初始化账号Client
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dingtalkworkflow_1_0.Client createClient(){
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkworkflow_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败");
        }
    }

    public static com.aliyun.dingtalkoauth2_1_0.Client createOauthClient(){
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkoauth2_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败(带权限)");
        }
    }

    public static com.aliyun.dingtalkstorage_1_0.Client createStorageClient(){
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkstorage_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败(存储)");
        }
    }

    public static com.aliyun.dingtalkdrive_1_0.Client createDriveClient(){
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkdrive_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败(文件操作)");
        }
    }

    public static com.aliyun.dingtalkyida_1_0.Client createClientYiDa(){
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkyida_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败(宜搭)");
        }
    }

    public static com.aliyun.dingtalkim_1_0.Client createClientIm(){
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkim_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败(卡片)");
        }
    }

    public static com.aliyun.dingtalkrobot_1_0.Client createClientRobot(){
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        try {
            return new com.aliyun.dingtalkrobot_1_0.Client(config);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("获取客户端连接失败(机器人)");
        }
    }
}
